{% extends 'admin_base.html' %}

{% block title %}

{% endblock %}

{% block head %}

{% endblock %}

{% block main %}
    <dl class="dl-horizontal">
        <dt>订单号</dt>
        <dd>{{ order.id }}</dd>
        <dt>用户名</dt>
        <dd>{{ order.user.name }}</dd>
        <dt>收货人</dt>
        <dd>{{ order.name }}</dd>
        <dt>收货地址</dt>
        <dd>{{ order.address }}</dd>
        <dt>联系电话</dt>
        <dd>{{ order.phone }}</dd>
        <dt>订单状态</dt>
        <dd>{{ order.state }}</dd>
        <dt>订单创建时间</dt>
        <dd>{{ order.create_time }}</dd>
        <dt>总价</dt>
        <dd>{{ order.payment_amount }}</dd>
    </dl>
    <table class="table table-hover show_modal">
        <tbody>
        {% for item in order.order_items %}
            <tr>
                <td style="vertical-align:middle;width: 30%">
                    <a href="javascript:void(0);" data-toggle="modal" data-target="#modal-comment-book"
                       data-url="{{ url_for('book_detail_customer',book_id=item.book.id) }}"
                       class="thumbnail">
                        <img src="{{ item.book.image_url }}" alt=""
                             style="height: 100px;">
                    </a>
                </td>
                <td style="vertical-align: middle;width: 25%">{{ item.book.name }}</td>
                <td style="vertical-align: middle;width: 15%">{{ item.quantity }}</td>
                <td style="vertical-align: middle">
                    <div class="input-group" style="width: 190px">
                        <div class="input-group-addon">￥</div>
                        <input type="text" class="form-control" value="{{ item.price }}" disabled>
                    </div>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    <form action="{{ url_for('admin_order_recipient_modify', order_id=order.id) }}">
        <fieldset id="fieldset_recipient" disabled>
            <div class="form-group">
                <label for="input_recipient_name">收货人</label>
                <input type="text" name="name" class="form-control" id="input_recipient_name" value="{{ order.name }}">
            </div>
            <div class="form-group">
                <label for="input_recipient_address">收货地址</label>
                <input type="text" class="form-control" id="input_recipient_address" name="address"
                       value="{{ order.address }}">
            </div>
            <div class="form-group">
                <label for="input_recipient_phone">联系电话</label>
                <input type="text" class="form-control" id="input_recipient_phone" name="phone"
                       value="{{ order.phone }}">
            </div>
            <button type="submit" class="btn" di>确定</button>
        </fieldset>
        {% if order.state == '待发货' %}
        <a id="alter_input" href="javaScrip:;">修改收货信息</a>
        {% endif %}
    </form>
    {% if order.state == '待发货' or order.state == '申请退货' or order.state == '同意退货' or order.state == '拒绝退货' %}
        <form action="{{ url_for('order_update', order_id=order.id) }}" method="post">
            <select id="select_state" class="form-control pull-left" name="state" style="width: 30%;">
                {% if order.state == '待发货' %}
                    <option value="待发货">待发货</option>
                    <option value="待收货">待收货</option>
                {% elif order.state == '申请退货' %}
                    <option value="申请退货">申请退货</option>
                    <option value="同意退货">同意退货</option>
                    <option value="拒绝退货">拒绝退货</option>
                {% elif order.state == '同意退货' %}
                    <option value="同意退货">同意退货</option>
                    <option value="已退货">已退货</option>
                {% else %}
                    <option value="拒绝退货">拒绝退货</option>
                    <option value="同意退货">同意退货</option>
                {% endif %}
                <option value="已完成">已完成</option>
                <option value="已取消">已取消</option>
            </select>
            <input class="btn btn-primary pull-left" type="submit" value="修改"/>
        </form>
    {% endif %}
    {#    模态框 #}
    <div class="modal fade modal-book-detail" tabindex="-1" role="dialog" id="modal-comment-book"
         aria-labelledby="exampleModalLabel">
    </div>
{% endblock %}